Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
ancient-mixins
Advanced tools
Core functions, classes, types and interfaces.
npm i --save ancient-mixins
Contents superclasses for mixins with your funcionality.
TypeScript typed events. Node EventEmitter based class for listening and emitting events.
import {
Events,
IEvents,
IEventsList,
} from 'ancient-mixins/lib/events';
interface ITestEventsList extends IEventsList {
a: { b: 'c', d?: 'e' };
}
class TestEvents extends Events implements IEvents<ITestEventsList> {}
const events: IEvents<ITestEventsList> = new TestEvents();
const listener = data => console.log('on', data);
events.on('a', listener);
events.on('b', listener);
events.once('a', data => console.log ('once', data));
events.emit('a', { b: 'c' });
// on { b: 'c' }
// once { b: 'c' }
events.emit('a', { d: 'e' });
// Error TS2345: Argument of type '{ d: "e"; }' is not assignable to parameter of type '{ b: "c"; d?: "e"; }'.
// Property 'b' is missing in type '{ d: "e"; }'.
events.emit('b', { x: 'y' });
// on { x: 'y' }. No error. It's because of extending ITestEventsList with IEventsList interface. Not specified events are allowed.
events.off('a', listener);
events.destroy();
Class Node make Events more material with unique id and isDestroyed state.
Unsafe class List to manipulate nodes.
import { List } from 'ancient-mixins/lib/list';
import { Node } from 'ancient-mixins/lib/node';
const list = new List();
const node = new Node();
List.on('anyNodeEvent', () => console.log ('anyNodeEvent'));
List.add(node);
node.emit('anyNodeEvent');
// anyNodeEvent
Class Manager gives control functionality for the lists of nodes and has own events. Contains class List, which has role to communicate node events and manager events.
import { Node } from 'ancient-mixins/lib/node';
import { Manager } from 'ancient-mixins/lib/manager';
const manager = new Manager();
const node = new Node();
manager.on('removed', () => console.log('removed'));
manager.on('added', () => console.log('added'));
manager.add(node);
// added
manager.remove(node);
// removed
manager.add(node);
// added
node.destroy();
// removed
FAQs
Core functions, classes, types and interfaces.
The npm package ancient-mixins receives a total of 0 weekly downloads. As such, ancient-mixins popularity was classified as not popular.
We found that ancient-mixins demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.